<?php

function bloc_annonce_aleatoire()
{
    $req = $GLOBALS['db']->prepare("SELECT id, ref, titre, titre_court, prix, photo_principale FROM ". PREFIX ."annonce WHERE photo_principale != '' AND active = 1 AND titre_court != '' ORDER BY RAND() LIMIT 1");
    $req->execute();
    $annonce = $req->fetch();
    $req->closeCursor();

    $GLOBALS['smarty']->assign('Annonce', $annonce);

    $b = $GLOBALS['smarty']->fetch('bloc_annonce_aleatoire.tpl');

    $GLOBALS['smarty']->clearAssign($Annonce);

    return $b;
}

?>
